package com.market.service.admin.impl;

import com.market.mapper.MarketSystemMapper;
import com.market.service.admin.AdminConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @Author:WalterChan
 * @Decription:AdminConfigServiceImpl
 * @Date Created in 2022-12-30-21:18
 */

@Service
public class AdminConfigServiceImpl implements AdminConfigService {

    @Autowired
    MarketSystemMapper marketSystemMapper;

    @Override
    public HashMap<String, String> list(ArrayList<String> list) {
        HashMap<String, String> resultMap = new HashMap<>();
        for (String keyName : list) {
            String value = marketSystemMapper.selectByKeyName(keyName);
            resultMap.put(keyName,value);
        }
        return resultMap;
    }

    @Override
    public HashMap<String, String> update(HashMap<String, String> map) {
        Date updateDate = new Date();
        ArrayList<String> keyList = new ArrayList<>();
        for (String key : map.keySet()) {
            marketSystemMapper.updateMallValueByKeyName(key,map.get(key),updateDate);
            System.out.println(map.get(key));
            keyList.add(key);
        }
        return list(keyList);
    }

}
